package com.xgjweb.fsi.service;

import java.util.List;

import com.xgjweb.common.dao.ICommonDao;
import com.xgjweb.common.service.CommonServiceImpl;
import com.xgjweb.common.utils.XgjWebLogger;
import com.xgjweb.fsi.domain.Song;

public class SongServiceImpl extends CommonServiceImpl implements ISongService {
	private ICommonDao songDao;

	public void setSongDao(ICommonDao songDao) {
		this.songDao = songDao;
	}

	/**
	 * 添加
	 */
	public Boolean addSong(Song song)
			throws Exception { 
		try {
			song.setStatementName("insertSong");
			songDao.insert(song);
			return true;
		} catch (RuntimeException e) {
			XgjWebLogger.getInstance().error(e.getMessage(), e);
			throw e;
		}
	}

	/**
	 * 删除
	 */
	public Boolean deleteSong(Song song) throws Exception {
		try {
			song.setStatementName("deleteSong");
			songDao.delete(song);
			return true;
		} catch (RuntimeException e) {
			XgjWebLogger.getInstance().error(e.getMessage(), e);
			throw e;
		}
	}

	/**
	 * 查找
	 */
	public Song findSong(Song song) throws Exception {
		try {
			song.setStatementName("findSong");
			song = (Song) songDao.selectByObject(song);
			return song;
		} catch (RuntimeException e) {
			XgjWebLogger.getInstance().error(e.getMessage(), e);
			throw e;
		}
	}

	/**
	 * 查询
	 */
	@SuppressWarnings("unchecked")
	public List<Song> querySong() throws Exception {
		try {
			Song song = new Song();
			song.setStatementName("querySong");
			List<Song> songs = songDao.selectByList(song);
			return songs;
		} catch (RuntimeException e) {
			XgjWebLogger.getInstance().error(e.getMessage(), e);
			throw e;
		}
	}

	/**
	 * 更新
	 */
	public Boolean updateSong(Song song) throws Exception {
		try {
			song.setStatementName("updateSong");
			songDao.update(song);
			return true;
		} catch (RuntimeException e) {
			XgjWebLogger.getInstance().error(e.getMessage(), e);
			throw e;
		}
	}

}
